﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;


namespace LinxDtefTelas
{
    public partial class FormDTEF : Form
    {
     
       

        public bool cancelClick;
        public bool OKClick;
        public string str;

        private static string _sOpcao;
        public static string sOpcao
        {
            get
            {
                // Reads are usually simple
                return _sOpcao;
            }
            set
            {
                // You can add logic here for race conditions,
                // or other measurements
                _sOpcao = value;
            }
        }

        public void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // FormDTEF
            // 
            this.ClientSize = new System.Drawing.Size(367, 151);
            this.KeyPreview = true;
            this.Name = "FormDTEF";
            this.ResumeLayout(false);

        }

  

        #region OnKeyPress
        protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
        {
            base.OnKeyPress(e);

            if (!char.IsNumber(e.KeyChar))
            {
                e.Handled = true;
            }


            if (cDtef.Expired == null && e.KeyChar == 8)
            {
                  e.Handled = false;

            }

            if (cDtef.Expired == "VendaCredito")
            {
                //MessageBox.Show("" + e.KeyChar.ToString());
                switch (e.KeyChar)
                {
                    case (char)8:
                    case (char)44:
                    case (char)46:
                        e.Handled = false;
                        break;
                }
            }
            else if (cDtef.Expired == "EntraValor")
            {
                
                switch (e.KeyChar)
                {

                    case (char)8:
                        e.Handled = false;
                        break;
                    case (char)44:
                    case (char)46:
                        e.Handled = false;
                        break;
                }
            
            }
            else if (cDtef.Expired == "EntraCartao")
            {
                switch (e.KeyChar)
                {
                    case (char)8:
                    case (char)44:
                    case (char)46:
                        e.Handled = false;
                        break;
                }
            }


            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                this.DialogResult = DialogResult.OK;
            }

           
            if (e.KeyChar == Convert.ToChar(Keys.Escape))
            {
                    
                cDtef.Expired = "EscapePressed";
                this.DialogResult = DialogResult.Cancel;
            }

            if (cDtef.Expired == "SelecionaOpcao")
            {
                if (e.KeyChar == Convert.ToChar(Keys.D1))
                {
                    _sOpcao = "1";
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                if (e.KeyChar == Convert.ToChar(Keys.D2))
                {
                    _sOpcao = "2";
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                if (e.KeyChar == Convert.ToChar(Keys.D3))
                {
                    _sOpcao = "3";
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }

        }
        #endregion


        public void Closer()
        {
            this.Close();
        }


    }
}
